home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////
- //original zdrojak: Jan Koci (koci.opengl.cz)//
- //upravil: Peter AdamΦφk //
- ///////////////////////////////////////////////
-
- // This is our bitset class for storing which face has already been drawn.
- // The bitset functionality isn't really taken advantage of in this version
- // since we aren't rendering by leafs and nodes.
- // T°φda pro uklßdßnφ ploÜek, kterΘ byly vykresleny.
-
- class K_CBitset
- {
- public: // Ve°ejnΘ
-
- // Initialize all the data members
- // V konstruktoru nastav bit a jeho velikost na 0
- K_CBitset() : m_puiBits(0), m_iSize(0) {}
-
- // This is our deconstructor
- // Destruktor
- ~K_CBitset()
- {
- // If we have valid memory, get rid of it
- // Jestli₧e je zapln∞na pam∞¥ bitov²ch dat, tak
- if(m_puiBits)
- {
- delete m_puiBits; // Vyma₧ bitovΘ data
- m_puiBits = NULL; // Nastav je na NULL
- }
- }
-
-
- ////////////////////////////////////////
- ////////////// Funkce //////////////////
- ////////////////////////////////////////
-
- // This resizes our bitset to a size so each face has a bit associated with it
- // Alokuj dostateΦnΘ mno₧stvφ bit∙ pro vÜechny ploÜky pro bitovΘ nastavenφ klastr∙
- void Resize(int i_count)
- {
- // Get the size of integers we need
- // Zφskej velikost v hodnot∞ integer
- m_iSize = i_count / 32 + 1;
-
- // Make sure we haven't already allocated memory for the bits
- // Vyma₧ alokovanou pam∞¥ bitu
- // Jestli₧e je zapln∞na pam∞¥ bitov²ch dat, tak
- if(m_puiBits)
- {
- delete m_puiBits; // Vyma₧ bit
- m_puiBits = 0; // Nastav ho na NULL
- }
-
- // Allocate the bits and initialize them
- // Alokuj pam∞¥ pro novß bitovß data a nastav jejich velikost podle hodnoty m_isize
- m_puiBits = new unsigned int[m_iSize];
- ClearAll(); // Nastav vÜechny bity na 0
- }
-
- // This does the binary math to set the desired bit
- // Nastavφ, ploÜku jako vykreslenou
- // Nastav bit na 1
- void Set(int i)
- {
- // Pou₧ij bitovΘ posuny
- m_puiBits[i >> 5] |= (1 << (i & 31));
- }
-
- // This returns if the desired bit slot is a 1 or a 0
- // Funkce zjiÜ¥uje jestli ploÜka, kterß mß b²t vykreslena,
- // nebyla ji₧ vykreslena
- // Vra¥ funkci bit 0, nebo 1
- int On(int i)
- {
- return m_puiBits[i >> 5] & (1 << (i & 31 ));
- }
-
- // This clears a bit to 0
- // Nastav bit na 0
- void Clear(int i)
- {
- // Pou₧ij bitovΘ posuny
- m_puiBits[i >> 5] &= ~(1 << (i & 31));
- }
-
- // This initializes the bits to 0
- // Nastav vÜechny bity na 0
- void ClearAll()
- {
- memset(m_puiBits, 0, sizeof(unsigned int) * m_iSize);
- }
-
- private: // SoukromΘ
-
- ////////////////////////////////////////
- ////////////// Prom∞nnΘ ////////////////
- ////////////////////////////////////////
-
-
- // Our private bit data that holds the bits and size
- unsigned int *m_puiBits; // Bitovß data
- int m_iSize; // Bitovß velikost
-
- };